package com.yaosc.cloud.userinfo.controller;

import com.yaosc.cloud.userinfo.entity.R;
import com.yaosc.cloud.userinfo.entity.UserInfo;
import com.yaosc.cloud.userinfo.service.UserInfoService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用户基本信息表 (UserInfo)表控制层
 *
 * @author Seven_Yao
 * @since 2021-12-14 10:27:04
 */
@RestController
@RequestMapping("/userInfo")
public class UserInfoController {
    /**
     * 服务对象
     */
    @Resource
    private UserInfoService userInfoService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public UserInfo selectOne(Long id) {
        return this.userInfoService.queryById(id);
    }

    /**
     * 新增
     */
    @PostMapping("/save")
    public R save(UserInfo userInfo) {
        userInfoService.insert(userInfo);
        return R.ok();
    }

    /**
     * 详情
     */
    @PostMapping("/detail")
    public R detail(Long id) {
        UserInfo userInfo = userInfoService.queryById(id);
        return R.ok(userInfo);
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(UserInfo userInfo) {
        userInfoService.update(userInfo);
        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(Long id) {
        userInfoService.deleteById(id);
        return R.ok();
    }


}
